﻿/**
 * ...
 * @author sminutoli
 */
import com.dmotiko.prune.*
import com.dmotiko.general.*
import mx.utils.Delegate;

class NewsSection extends Section
{
	
	private var mcScroll:MovieClip;
	private var sun_listener:Function;
	private var mcNews:MovieClip;
	
	private function initClip():Void {
		super.initClip();
		this._x = 245;
		this._y = 96;
		sun_listener = Delegate.create(this, sun_hidden);
		Site.getApp().addEventListener( WebSite.SECTION_CHANGED, Delegate.create( this, section_changed ) );
	}
	
	private function section_changed(e):Void 
	{
		if ( e.section == SiteSections.NEWS ) {
			
			Site.getApp().getClips().getSol().addEventListener( BaseClipEvent.CHANGED, sun_listener );			
			
		} else {
			hide();
		}
	}
	
	private function sun_hidden():Void 
	{
		if ( Site.getApp().getSection() != SiteSections.NEWS ) return;
		Site.getApp().getClips().getSol().removeEventListener( BaseClipEvent.CHANGED, sun_listener );
		show();
		mcNews = attachMovie("NewsContainer", "mcNews", mcNews ? mcNews.getDepth() : this.getNextHighestDepth() );
	}
		
}